package com.servlet.article;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.ArticleDAO;

public class DelectArticleByIdServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int articleId = Integer.parseInt(request.getParameter("article_id"));
		ArticleDAO articlesDAO = new ArticleDAO();// 得到DAO对象
		if (articlesDAO.delectById(articleId)) {
			request.getRequestDispatcher("/servlet/FindAllArticleServlet")
					.forward(request, response);
			return;
		}

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		int articleId = Integer.parseInt(request.getParameter("article_id"));
		ArticleDAO articlesDAO = new ArticleDAO();// 得到DAO对象
		if (articlesDAO.delectById(articleId)) {
			request.getRequestDispatcher("/servlet/FindAllArticleServlet")
					.forward(request, response);
			return;
		}
	}

}
